<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- <meta name="viewport" content="width=device-width, initial-scale=1.0"> -->
    <script src="http://47.104.209.44/base/js/jquery-1.10.1.min.js"></script>

    <title>300 ms 延迟</title>
    <style>
        h1 {
            text-align: center;
        }

        .item {
            width: 90%;
            padding: 20px 0;
            text-align: center;
            border: 1px solid darkturquoise;
            border-radius: 10px;
            margin: 30px auto;
        }

        span {
            color: red;
            font-size: 40px;
        }
    </style>
</head>

<body>
    <h1>300 ms 延迟的故事
    </h1>
    <p class="tp item">
        touch
        <span class="ts">00</span>
        ms
    </p>

    <p class="cp item">
        touch
        <span class="cs">00</span>
        ms
    </p>
</body>
<script>
    var start = 0;
    var end = 0;
    // touch 事件

    $(".tp").on("touchstart", function () {
        start = new Date()
    })

    $(".tp").on("touchend", function () {
        end = new Date()
        $(".ts").html(end - start)
    })

    // click 事件  慢300ms
    $(".cp").on("touchstart", function () {
        start = new Date()
    })

    $(".cp").on("click", function () {
        end = new Date()
        $(".cs").html(end - start)
    })
</script>

</html>